<?php include_once 'config.php'; 
#array_walk_recursive($_POST,'Classes_MySQL::escape'); 
print_r($_POST);
if(isset($_POST['btn_contactus'])){ 
	if(!empty($_POST['email']) && !empty($_POST['message']) && !empty($_POST['name'])){
		$tpl = file_get_contents(TEMPLATE.'/contactus.tpl.html');
		$tpl = trim($tpl);
		$replace_to[] = '/{name}/';
		$replace_with[] = ucwords(strtolower($_POST['name']));
		$replace_to[] = '/{email}/';
		$replace_with[] = $_POST['email'];
		$replace_to[] = '/{message}/';
		$replace_with[] = $_POST['message'];
		
		$tpl = preg_replace($replace_to,$replace_with,$tpl);
		
		$mail             = new PHPMailer();		
		$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test		
		$mail->IsSMTP();
		$mail->SMTPAuth   = true;
		$mail->SMTPSecure = "ssl";
		$mail->Host       = "smtp.gmail.com";
		$mail->Port       = 465;
		$mail->Username   = "no-reply@jeth-ro.com";
		$mail->Password   = "comrad4254";
		$mail->AddReplyTo($_POST['email'],ucwords(strtolower($_POST['name'])));
		$mail->From       = $_POST['email'];
		$mail->FromName   = ucwords(strtolower($_POST['name']));
		$mail->Subject    = "CONTACT US :: ".DOMAIN;
		$mail->MsgHTML($tpl);
		$mail->AddAddress(MAIL_FROM);
		$mail->AddBCC("jet_lav@yahoo.com");
		if($mail->Send()) echo "ERROR"; else echo "MAIL SENT";
	}
}
?>